|
|
|
|
|
|
|
Solution 21
What Is That Mapped Drive? Part 1 |
|
|
|
|
|
|
|
|
Was it a Windows bug, a bug in the MapInfo1 project, or a documentation error? |
|
|
|
|
|
|
|
|
It depends on your point of view and your interpretation of the documentation. |
|
|
|
|
|
|
|
|
The following code from the GetMappedInfo function in the MapInfol.vbp project (on the CD that comes with this book) lies at the heart of the matter: |
|
|
|
|
|
|
|
|
res = WNetGetConnection(Drive, Buffer, BufferLength)
If res = ERROR_MORE_DATA Then
Buffer = String$(BufferLength, 0)
res = WNetGetConnection(Drive, Buffer, BufferLength)
End If |
|
|
|
|
|
|
|
|
The API documentation says this of the BufferLength parameter: |
|
|
|
 |
|
 |
|
|
If the function fails because the buffer is not big enough, this parameter returns the required buffer size. |
|
|
|
|
|
|
|
|
One interpretation of this comment is that the buffer size returned will be sufficient for the function to succeed. In other words, once you call this to obtain the correct buffer size, it should not be possible for the function to return the ERROR_MORE_DATA return value. I think most reasonable people would see it this way; I certainly did. |
|
|
|
|
|
|
|
|
But you could also interpret this to mean that it returns the required buffer size for the next attempt. If the buffer size was still not large enough, the function would return the ERROR_MORE_DATA result again with a new buffer size that will hopefully be large enough to hold all of the data. |
|
|
|
|
|